package com.ihr360.payroll.controller.salarytax;

import com.ihr360.maven.plugin.ModuleCodeStore;
import com.ihr360.maven.plugin.annotation.FunctionDefinition;
import com.ihr360.maven.plugin.annotation.ModuleDefinition;
import com.ihr360.payroll.model.dto.salary.basecode.TaxDivision;
import com.ihr360.payroll.service.salarytax.TaxDivisionService;
import com.ihr360.rest.service.SimpleRestService;
import com.ihr360.rest.webmvc.AbstractRestSimpleWithLongIdController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author richey
 */
@RestController
@RequestMapping("/taxDivisions")
@ModuleDefinition(mainModuleCode = ModuleCodeStore.Module.SALARY_CODE_ADMIN, mainModuleName = ModuleCodeStore.Module.SALARY_NAME_ADMIN, hasExtendsAbstractRestController = true,
        subModuleCode = ModuleCodeStore.Module.SalaryAdmin.TAX_TABLE_CODE, subModuleName = ModuleCodeStore.Module.SalaryAdmin.TAX_TABLE_NAME)
public class TaxDivisionController extends AbstractRestSimpleWithLongIdController<TaxDivision> {

    @Autowired
    private TaxDivisionService taxDivisionService;

    @Override
    public SimpleRestService<TaxDivision, Long> getSimpleRestService() {
        return taxDivisionService;
    }

    @ApiOperation(value = "获取纳税地区列表")
    @GetMapping(value = "/taxDivisionList")
    @FunctionDefinition(functionName = "获取纳税地区列表", functionCode = ModuleCodeStore.Function.VIEW, isPublic = true)
    public List<TaxDivision> taxDivisionList() {
        return (List<TaxDivision>) taxDivisionService.getAll();
    }
}
